/* eslint-disable */
// const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const TIMESTAMP = Date.parse(new Date());
// const CDN_ADDRESS = {
//     static: "https://h5.u51.com/99fenqi/vue"
// };

module.exports = (() => {
    let prodConfig = {
        chainWebpack: config => {
            // config.plugins.delete("preload"),
        }
    };
    if (process.env.NODE_ENV === "production") {
        // mutate config for production...
        prodConfig = Object.assign({}, {
            // outputDir: `dist/static/${TIMESTAMP}/`,
            // baseUrl: CDN_ADDRESS.static + "/static/" + TIMESTAMP + "/",
            outputDir: `dist/static/${TIMESTAMP}/`,
            baseUrl: "./static/" + TIMESTAMP + "/",
            indexPath: '../../index.html', //指定生成的 index.html 的输出路径(相对于 outputDir)也可以是一个绝对路径。
            configureWebpack: {
                output: {
                    filename: "[name].[hash:10].js",
                    chunkFilename: "[id].[hash:10].js",
                },
                plugins: [
                    /**
                     * console 打包处理
                     */
                    // new UglifyJsPlugin({
                    //     uglifyOptions: {
                    //         compress: {
                    //             warnings: false,
                    //             drop_console: true
                    //         },
                    //         output: {
                    //             // 去掉注释内容
                    //             comments: false
                    //         }
                    //     },
                    //     sourceMap: false,
                    //     parallel: true
                    // }),
                ]
            }
        });
    } else {
        prodConfig = Object.assign({}, {
            configureWebpack: {
                devtool: "eval-source-map",
                output: {
                },
                plugins: [
                ]
            },
            devServer: {
                // 端口号
                port: 9997,
                // 自动打开浏览器
                open:true,
                // disableHostCheck: true,
                // proxy: {
                //     "yw/*": {
                //         target: "http://39.102.37.117:8600/", // test
                //         changeOrigin: true,
                //         logLevel: "debug",
                //         // pathRewrite: {"^/yw" : ""},
                //     },
                // },
                // proxy: {
                //     'yw/*': {
                //         target: 'http://39.102.37.117:8600/',
                //         changeOrigin: true,
                //         logLevel: "debug",
                //         pathRewrite: {"^/yw" : ""}
                //         // secure: false,
                //     },
                // },
            }
        });
    }
    return prodConfig;
})();
